package types

import (
	"fmt"
	"net/http"
)

const (
	AuthorizationHeader = "Authorization"
	AuthorizationPrefix = "Bearer "
	ModelMatchHeader    = "X-Model-ID"
)

var ChatRequestHeaders = []string{
	ModelMatchHeader,
}

type Headers = []string

func HasAllRequestHeaders(headers Headers, r *http.Request) error {
	var lackHeader []string
	var err error
	headersToCheck := r.Header
	for _, header := range headers {
		if header != "" && headersToCheck.Get(header) == "" {
			lackHeader = append(lackHeader, header)
		}
	}
	if len(lackHeader) > 0 {
		err = fmt.Errorf("missing required headers: %v", lackHeader)
		return err
	}
	return nil
}

func HasAllChatRequestHeaders(r *http.Request) error {
	return HasAllRequestHeaders(ChatRequestHeaders, r)
}
